<?php
session_start();
$name = $_SESSION['user'];
$money = $_POST['money'];
$payer = $_POST['payer'];
$pdo =new PDO("mysql:host=127.0.0.1;dbname=seven","root","root");
$pdo->beginTransaction();
$select = $pdo->query("select * from login where user = '$name'")->fetch();
$num1 = $pdo->exec("update login set money = money - '$money' where user = '$name'");
$num2 = $pdo->exec("update login set money = money + '$money' where user = '$payer'");
if($num1>0&&$num2>0&&$select['money']>='$money')
{
	$pdo->commit();
}
else
{
	$pdo->rollBack();
}